using Unity.Entities;
using UnityEngine;

namespace DOTS.DOD.LESSON3
{
    struct CubeGeneratorByPrefab : IComponentData
    {
        public Entity CubeEntityProtoType;
        public int CubeCount;
    }

    public class CubeGeneratorByPrefabAuthoring : MonoSingleton<CubeGeneratorByPrefabAuthoring>
    {
        public GameObject CubeArchetype;
        public int CubeCount;

        class Baker : Baker<CubeGeneratorByPrefabAuthoring>
        {
            public override void Bake(CubeGeneratorByPrefabAuthoring authoring)
            {
                var entity = GetEntity(TransformUsageFlags.None);
                AddComponent(entity, new CubeGeneratorByPrefab()
                {
                    CubeEntityProtoType = GetEntity(authoring.CubeArchetype, TransformUsageFlags.Dynamic),
                    CubeCount = authoring.CubeCount,
                });
            }
        }
    }
}